<template>
  <div class="container-item-classify">
    <div v-for="(temp,index) in value" :key="index" class="item-list-box" @click="routerLink(`productDetails`,temp.id)">
      <div class="item-list">
        <van-image width="100%" height="100%" :src="temp.img" fit="cover" />
        <div class="listName">{{ temp.product_name }}</div>
        <div class="listPrise"> ￥ <span>{{ temp.money | saveNum }}</span> </div>
      </div>
    </div>
    <div v-if="value.length === 0" class="item-nomore">暂无该类商品</div>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: ''
    },
    cover: {
      type: String,
      default: 'http://placehold.it/120x120'
    },
    value: {
      type: Array,
      required: true
    }
  },
  mounted() {
    console.log(this.value)
  },
  methods: {
    routerLink(name, id) {
      console.log('分类列表点击-log:', name, id)
      this.$router.push({ name, params: { id }})
    }
  }
}
</script>

<style lang="less">
.container-item-classify {
  width: 100%;
  max-height: 100%;
  display: flex;
  flex-wrap: wrap;
  overflow-y: scroll;
  background: #f5f6f8;
  .item-list {
    // width: 120px;
    width: 95%;
    box-shadow: 0 0 2px #ddd;
    border-radius: 5px;
    overflow: hidden;
    background: #fff;
  }
  .item-nomore {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    color: #999;
  }
  .item-list-box {
    width: 50%;
    padding: 5px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    .listPic {
      width: 120px;
      img {
        width: 100%;
      }
    }
    .listName {
      font-size: 14px;
      color: #000;
      font-weight: bold;
      padding: 5px;
      width: 95%;
    }
    .listPrise {
      color: #d63a54;
      font-size: 16px;
      span {
        font-size: 20px;
      }
    }
  }
}
</style>
